package org.htmlparser.lexer;

import java.io.PrintStream;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URLConnection;
import java.util.Vector;
import org.htmlparser.Node;
import org.htmlparser.NodeFactory;
import org.htmlparser.Remark;
import org.htmlparser.Tag;
import org.htmlparser.Text;
import org.htmlparser.http.ConnectionManager;
import org.htmlparser.nodes.RemarkNode;
import org.htmlparser.nodes.TagNode;
import org.htmlparser.nodes.TextNode;
import org.htmlparser.util.ChainedException;
import org.htmlparser.util.ParserException;

public class Lexer
  implements Serializable, NodeFactory
{
  public static boolean STRICT_REMARKS = 0;
  public static final String VERSION_DATE = "Jun 10, 2006";
  public static final double VERSION_NUMBER = 1.6000000000000001D;
  public static final String VERSION_STRING = "1.6 (Release Build Jun 10, 2006)";
  public static final String VERSION_TYPE = "Release Build";
  protected static int mDebugLineTrigger = -1;
  protected Cursor mCursor;
  protected NodeFactory mFactory;
  protected Page mPage;

  public Lexer()
  {
    this(new Page(""));
  }

  public Lexer(String paramString)
  {
    this(new Page(paramString));
  }

  public Lexer(URLConnection paramURLConnection)
    throws ParserException
  {
    this(new Page(paramURLConnection));
  }

  public Lexer(Page paramPage)
  {
    setPage(paramPage);
    setCursor(new Cursor(paramPage, 0));
    setNodeFactory(this);
  }

  private void double_quote(Vector paramVector, int[] paramArrayOfInt)
  {
    paramVector.addElement(new PageAttribute(this.mPage, paramArrayOfInt[1], paramArrayOfInt[2], 1 + paramArrayOfInt[5], paramArrayOfInt[6], '"'));
  }

  private void empty(Vector paramVector, int[] paramArrayOfInt)
  {
    paramVector.addElement(new PageAttribute(this.mPage, paramArrayOfInt[1], paramArrayOfInt[2], 1 + paramArrayOfInt[2], -1, '));
  }

  public static String getVersion()
  {
    return "1.6 (Release Build Jun 10, 2006)";
  }

  public static void main(String[] paramArrayOfString)
    throws MalformedURLException, ParserException
  {
    if (paramArrayOfString.length <= 0)
    {
      System.out.println("HTML Lexer v" + getVersion() + "\n");
      System.out.println();
      System.out.println("usage: java -jar htmllexer.jar <url>");
      return;
    }
    try
    {
      Node localNode;
      do
      {
        Lexer localLexer = new Lexer(Page.getConnectionManager().openConnection(paramArrayOfString[0]));
        localNode = localLexer.nextNode(false);
      }
      while (localNode == null);
      System.out.println(localNode.toString());
    }
    catch (ParserException localParserException)
    {
      while (true)
      {
        do
          System.out.println(localParserException.getMessage());
        while (localParserException.getThrowable() == null);
        System.out.println(localParserException.getThrowable().getMessage());
      }
    }
  }

  private void naked(Vector paramVector, int[] paramArrayOfInt)
  {
    paramVector.addElement(new PageAttribute(this.mPage, paramArrayOfInt[1], paramArrayOfInt[2], paramArrayOfInt[3], paramArrayOfInt[4], '));
  }

  private void single_quote(Vector paramVector, int[] paramArrayOfInt)
  {
    paramVector.addElement(new PageAttribute(this.mPage, paramArrayOfInt[1], paramArrayOfInt[2], 1 + paramArrayOfInt[4], paramArrayOfInt[5], '\''));
  }

  private void standalone(Vector paramVector, int[] paramArrayOfInt)
  {
    paramVector.addElement(new PageAttribute(this.mPage, paramArrayOfInt[1], paramArrayOfInt[2], -1, -1, '));
  }

  private void whitespace(Vector paramVector, int[] paramArrayOfInt)
  {
    if (paramArrayOfInt[1] > paramArrayOfInt[0])
      paramVector.addElement(new PageAttribute(this.mPage, -1, -1, paramArrayOfInt[0], paramArrayOfInt[1], '));
  }

  public Remark createRemarkNode(Page paramPage, int paramInt1, int paramInt2)
  {
    return new RemarkNode(paramPage, paramInt1, paramInt2);
  }

  public Text createStringNode(Page paramPage, int paramInt1, int paramInt2)
  {
    return new TextNode(paramPage, paramInt1, paramInt2);
  }

  public Tag createTagNode(Page paramPage, int paramInt1, int paramInt2, Vector paramVector)
  {
    return new TagNode(paramPage, paramInt1, paramInt2, paramVector);
  }

  public String getCurrentLine()
  {
    return getPage().getLine(getCursor());
  }

  public int getCurrentLineNumber()
  {
    return getPage().row(getCursor());
  }

  public Cursor getCursor()
  {
    return this.mCursor;
  }

  public NodeFactory getNodeFactory()
  {
    return this.mFactory;
  }

  public Page getPage()
  {
    return this.mPage;
  }

  public int getPosition()
  {
    return getCursor().getPosition();
  }

  protected Node makeRemark(int paramInt1, int paramInt2)
    throws ParserException
  {
    Remark localRemark;
    Object localObject;
    int i = paramInt2 - paramInt1;
    if (i != 0)
    {
      if (2 > i)
      {
        localObject = makeString(paramInt1, paramInt2);
        return localObject;
      }
      localRemark = getNodeFactory().createRemarkNode(getPage(), paramInt1, paramInt2);
    }
    while (true)
    {
      while (true)
        localObject = localRemark;
      localRemark = null;
    }
  }

  protected Node makeString(int paramInt1, int paramInt2)
    throws ParserException
  {
    Text localText;
    if (paramInt2 - paramInt1 != 0)
      localText = getNodeFactory().createStringNode(getPage(), paramInt1, paramInt2);
    while (true)
    {
      return localText;
      localText = null;
    }
  }

  protected Node makeTag(int paramInt1, int paramInt2, Vector paramVector)
    throws ParserException
  {
    Tag localTag;
    Object localObject;
    int i = paramInt2 - paramInt1;
    if (i != 0)
    {
      if (2 > i)
      {
        localObject = makeString(paramInt1, paramInt2);
        return localObject;
      }
      localTag = getNodeFactory().createTagNode(getPage(), paramInt1, paramInt2, paramVector);
    }
    while (true)
    {
      while (true)
        localObject = localTag;
      localTag = null;
    }
  }

  public Node nextNode()
    throws ParserException
  {
    return nextNode(false);
  }

  public Node nextNode(boolean paramBoolean)
    throws ParserException
  {
    Node localNode;
    if (-1 != mDebugLineTrigger)
    {
      int l = getPage().row(this.mCursor);
      if (mDebugLineTrigger < l)
        mDebugLineTrigger = l + 1;
    }
    int i = this.mCursor.getPosition();
    switch (this.mPage.getCharacter(this.mCursor))
    {
    default:
      this.mPage.ungetCharacter(this.mCursor);
      localNode = parseString(i, paramBoolean);
    case '￿':
    case '<':
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          int k;
          while (true)
          {
            while (true)
            {
              int j;
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        return localNode;
                        localNode = null;
                      }
                      j = this.mPage.getCharacter(this.mCursor);
                      if (65535 != j)
                        break;
                      localNode = makeString(i, this.mCursor.getPosition());
                    }
                    if (37 != j)
                      break;
                    this.mPage.ungetCharacter(this.mCursor);
                    localNode = parseJsp(i);
                  }
                  if (63 != j)
                    break;
                  this.mPage.ungetCharacter(this.mCursor);
                  localNode = parsePI(i);
                }
                if ((47 != j) && (37 != j) && (!(Character.isLetter(j))))
                  break;
                this.mPage.ungetCharacter(this.mCursor);
                localNode = parseTag(i);
              }
              if (33 != j)
                break label354;
              k = this.mPage.getCharacter(this.mCursor);
              if (65535 != k)
                break;
              localNode = makeString(i, this.mCursor.getPosition());
            }
            if (62 != k)
              break;
            localNode = makeRemark(i, this.mCursor.getPosition());
          }
          this.mPage.ungetCharacter(this.mCursor);
          if (45 != k)
            break;
          localNode = parseRemark(i, paramBoolean);
        }
        this.mPage.ungetCharacter(this.mCursor);
        localNode = parseTag(i);
      }
      label354: localNode = parseString(i, paramBoolean);
    }
  }

  public Node parseCDATA()
    throws ParserException
  {
    return parseCDATA(false);
  }

  public Node parseCDATA(boolean paramBoolean)
    throws ParserException
  {
    int i = this.mCursor.getPosition();
    int j = 0;
    int k = 0;
    int l = 0;
    int i1 = 0;
    while (true)
    {
      while (true)
      {
        while (true)
        {
          label468: label600: int i4;
          while (true)
          {
            int i3;
            while (true)
            {
              int i2;
              do
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          while (true)
                          {
                            while (true)
                            {
                              int i6;
                              while (true)
                              {
                                int i5;
                                while (true)
                                {
                                  while (true)
                                  {
                                    while (true)
                                    {
                                      while (true)
                                      {
                                        while (true)
                                        {
                                          while (true)
                                          {
                                            do
                                            {
                                              while (true)
                                              {
                                                while (true)
                                                {
                                                  int i7;
                                                  int i9;
                                                  while (true)
                                                  {
                                                    while (true)
                                                    {
                                                      do
                                                        while (true)
                                                        {
                                                          int i10;
                                                          do
                                                            while (true)
                                                            {
                                                              do
                                                                while (true)
                                                                {
                                                                  do
                                                                    while (true)
                                                                    {
                                                                      do
                                                                        while (true)
                                                                        {
                                                                          do
                                                                            while (true)
                                                                            {
                                                                              do
                                                                                while (true)
                                                                                {
                                                                                  while (true)
                                                                                  {
                                                                                    while (true)
                                                                                    {
                                                                                      if (k != 0)
                                                                                        break label806;
                                                                                      i2 = this.mPage.getCharacter(this.mCursor);
                                                                                      switch (j)
                                                                                      {
                                                                                      default:
                                                                                        throw new IllegalStateException("how the fuck did we get in state " + j);
                                                                                      case 0:
                                                                                        switch (i2)
                                                                                        {
                                                                                        default:
                                                                                        case 10:
                                                                                        case 65535:
                                                                                        case 39:
                                                                                        case 34:
                                                                                        case 92:
                                                                                        case 47:
                                                                                        case 60:
                                                                                        }
                                                                                      case 1:
                                                                                      case 2:
                                                                                      case 3:
                                                                                      }
                                                                                    }
                                                                                    i1 = 0;
                                                                                  }
                                                                                  k = 1;
                                                                                }
                                                                              while ((!(paramBoolean)) || (i1 != 0));
                                                                              if (l != 0)
                                                                                break;
                                                                              l = 39;
                                                                            }
                                                                          while (39 != l);
                                                                          l = 0;
                                                                        }
                                                                      while ((!(paramBoolean)) || (i1 != 0));
                                                                      if (l != 0)
                                                                        break;
                                                                      l = 34;
                                                                    }
                                                                  while (34 != l);
                                                                  l = 0;
                                                                }
                                                              while ((!(paramBoolean)) || (l == 0));
                                                              i10 = this.mPage.getCharacter(this.mCursor);
                                                              if (65535 != i10)
                                                                break;
                                                              k = 1;
                                                            }
                                                          while ((i10 == 92) || (i10 == l));
                                                          this.mPage.ungetCharacter(this.mCursor);
                                                        }
                                                      while ((!(paramBoolean)) || (l != 0));
                                                      i7 = this.mPage.getCharacter(this.mCursor);
                                                      if (65535 != i7)
                                                        break;
                                                      k = 1;
                                                    }
                                                    if (47 != i7)
                                                      break;
                                                    i1 = 1;
                                                  }
                                                  if (42 != i7)
                                                    break;
                                                  do
                                                    do
                                                    {
                                                      int i8;
                                                      do
                                                        i8 = this.mPage.getCharacter(this.mCursor);
                                                      while ((65535 != i8) && (42 != i8));
                                                      i9 = this.mPage.getCharacter(this.mCursor);
                                                      if (i9 == 42)
                                                        this.mPage.ungetCharacter(this.mCursor);
                                                    }
                                                    while (65535 == i9);
                                                  while (47 != i9);
                                                }
                                                this.mPage.ungetCharacter(this.mCursor);
                                              }
                                              if (!(paramBoolean))
                                                break label468;
                                            }
                                            while (l != 0);
                                            j = 1;
                                          }
                                          j = 1;
                                        }
                                        switch (i2)
                                        {
                                        default:
                                          j = 0;
                                        case 65535:
                                        case 47:
                                        case 33:
                                        }
                                      }
                                      k = 1;
                                    }
                                    j = 2;
                                  }
                                  i5 = this.mPage.getCharacter(this.mCursor);
                                  if (65535 != i5)
                                    break;
                                  k = 1;
                                }
                                if (45 != i5)
                                  break label600;
                                i6 = this.mPage.getCharacter(this.mCursor);
                                if (65535 != i6)
                                  break;
                                k = 1;
                              }
                              if (45 != i6)
                                break;
                              j = 3;
                            }
                            j = 0;
                          }
                          j = 0;
                        }
                        i1 = 0;
                        if (65535 != i2)
                          break;
                        k = 1;
                      }
                      if (!(Character.isLetter(i2)))
                        break;
                      k = 1;
                      this.mPage.ungetCharacter(this.mCursor);
                      this.mPage.ungetCharacter(this.mCursor);
                      this.mPage.ungetCharacter(this.mCursor);
                    }
                    j = 0;
                  }
                  i1 = 0;
                  if (65535 != i2)
                    break;
                  k = 1;
                }
              while (45 != i2);
              i3 = this.mPage.getCharacter(this.mCursor);
              if (65535 != i3)
                break;
              k = 1;
            }
            if (45 != i3)
              break label792;
            i4 = this.mPage.getCharacter(this.mCursor);
            if (65535 != i4)
              break;
            k = 1;
          }
          if (62 != i4)
            break;
          j = 0;
        }
        this.mPage.ungetCharacter(this.mCursor);
        this.mPage.ungetCharacter(this.mCursor);
      }
      label792: this.mPage.ungetCharacter(this.mCursor);
    }
    label806: return makeString(i, this.mCursor.getPosition());
  }

  protected Node parseJsp(int paramInt)
    throws ParserException
  {
    label645: Node localNode;
    int i = 0;
    int j = 0;
    int k = 0;
    Vector localVector = new Vector();
    while (true)
    {
      while (true)
      {
        while (true)
        {
          int i1;
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          int i2;
                          int i4;
                          while (true)
                          {
                            int i5;
                            while (true)
                            {
                              while (true)
                              {
                                while (true)
                                {
                                  while (true)
                                  {
                                    while (true)
                                    {
                                      while (true)
                                      {
                                        while (true)
                                        {
                                          while (true)
                                          {
                                            while (true)
                                            {
                                              if (i != 0)
                                                break label645;
                                              i1 = this.mPage.getCharacter(this.mCursor);
                                              switch (j)
                                              {
                                              default:
                                                throw new IllegalStateException("how the fuck did we get in state " + j);
                                              case 0:
                                                switch (i1)
                                                {
                                                default:
                                                  i = 1;
                                                case 37:
                                                }
                                              case 1:
                                              case 2:
                                              case 3:
                                              case 34:
                                              case 39:
                                              }
                                            }
                                            j = 1;
                                          }
                                          switch (i1)
                                          {
                                          default:
                                            k = this.mCursor.getPosition() - 1;
                                            localVector.addElement(new PageAttribute(this.mPage, paramInt + 1, k, -1, -1, '));
                                            j = 2;
                                          case 62:
                                          case 65535:
                                          case 61:
                                          case 64:
                                          }
                                        }
                                        i = 1;
                                      }
                                      k = this.mCursor.getPosition();
                                      localVector.addElement(new PageAttribute(this.mPage, paramInt + 1, k, -1, -1, '));
                                      j = 2;
                                    }
                                    switch (i1)
                                    {
                                    default:
                                    case 34:
                                    case 39:
                                    case 62:
                                    case 65535:
                                    case 37:
                                    case 47:
                                    }
                                  }
                                  j = i1;
                                }
                                i = 1;
                              }
                              j = 3;
                            }
                            i2 = this.mPage.getCharacter(this.mCursor);
                            if (i2 != 47)
                              break;
                            do
                              do
                                while (true)
                                {
                                  i5 = this.mPage.getCharacter(this.mCursor);
                                  if (i5 != 65535)
                                    break;
                                  i = 1;
                                }
                              while (i5 == 10);
                            while (i5 != 13);
                          }
                          if (i2 != 42)
                            break;
                          do
                            do
                            {
                              int i3;
                              do
                                i3 = this.mPage.getCharacter(this.mCursor);
                              while ((65535 != i3) && (42 != i3));
                              i4 = this.mPage.getCharacter(this.mCursor);
                              if (i4 == 42)
                                this.mPage.ungetCharacter(this.mCursor);
                            }
                            while (65535 == i4);
                          while (47 != i4);
                        }
                        this.mPage.ungetCharacter(this.mCursor);
                      }
                      switch (i1)
                      {
                      default:
                        j = 2;
                      case 65535:
                      case 62:
                      }
                    }
                    i = 1;
                  }
                  j = 4;
                  i = 1;
                }
                switch (i1)
                {
                default:
                case 34:
                case 65535:
                }
              }
              j = 2;
            }
            i = 1;
          }
          switch (i1)
          {
          default:
          case 39:
          case 65535:
          }
        }
        j = 2;
      }
      i = 1;
    }
    if (4 == j)
      if (k != 0)
      {
        int l = this.mCursor.getPosition() - 2;
        localVector.addElement(new PageAttribute(this.mPage, k, l, -1, -1, '));
        localVector.addElement(new PageAttribute(this.mPage, l, l + 1, -1, -1, '));
        localNode = makeTag(paramInt, this.mCursor.getPosition(), localVector);
      }
    while (true)
    {
      return localNode;
      throw new IllegalStateException("jsp with no code!");
      localNode = parseString(paramInt, true);
    }
  }

  protected Node parsePI(int paramInt)
    throws ParserException
  {
    label373: Node localNode;
    int i = 0;
    int j = 0;
    int k = 0;
    Vector localVector = new Vector();
    while (true)
    {
      while (true)
      {
        while (true)
        {
          int i1;
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          while (true)
                          {
                            while (true)
                            {
                              while (true)
                              {
                                while (true)
                                {
                                  if (i != 0)
                                    break label373;
                                  i1 = this.mPage.getCharacter(this.mCursor);
                                  switch (j)
                                  {
                                  default:
                                    throw new IllegalStateException("how the fuck did we get in state " + j);
                                  case 0:
                                    switch (i1)
                                    {
                                    default:
                                      i = 1;
                                    case 63:
                                    }
                                  case 1:
                                  case 2:
                                  case 34:
                                  case 39:
                                  }
                                }
                                k = this.mCursor.getPosition();
                                localVector.addElement(new PageAttribute(this.mPage, paramInt + 1, k, -1, -1, '));
                                j = 1;
                              }
                              switch (i1)
                              {
                              default:
                              case 34:
                              case 39:
                              case 62:
                              case 65535:
                              case 63:
                              }
                            }
                            j = i1;
                          }
                          i = 1;
                        }
                        j = 2;
                      }
                      switch (i1)
                      {
                      default:
                        j = 1;
                      case 65535:
                      case 62:
                      }
                    }
                    i = 1;
                  }
                  j = 3;
                  i = 1;
                }
                switch (i1)
                {
                default:
                case 34:
                case 65535:
                }
              }
              j = 1;
            }
            i = 1;
          }
          switch (i1)
          {
          default:
          case 39:
          case 65535:
          }
        }
        j = 1;
      }
      i = 1;
    }
    if (3 == j)
      if (k != 0)
      {
        int l = this.mCursor.getPosition() - 2;
        localVector.addElement(new PageAttribute(this.mPage, k, l, -1, -1, '));
        localVector.addElement(new PageAttribute(this.mPage, l, l + 1, -1, -1, '));
        localNode = makeTag(paramInt, this.mCursor.getPosition(), localVector);
      }
    while (true)
    {
      return localNode;
      throw new IllegalStateException("processing instruction with no content");
      localNode = parseString(paramInt, true);
    }
  }

  protected Node parseRemark(int paramInt, boolean paramBoolean)
    throws ParserException
  {
    int k;
    int i = 0;
    int j = 0;
    while (true)
    {
      while (true)
      {
        if (i != 0)
          break label302;
        k = this.mPage.getCharacter(this.mCursor);
        if (65535 != k)
          break;
        i = 1;
      }
      switch (j)
      {
      default:
        throw new IllegalStateException("how the fuck did we get in state " + j);
      case 0:
        if (62 == k)
          i = 1;
        if (45 != k)
          break;
        j = 1;
      case 1:
      case 2:
      case 3:
      case 4:
      }
    }
    Node localNode = parseString(paramInt, paramBoolean);
    while (true)
    {
      while (true)
      {
        do
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  do
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          while (true)
                          {
                            int l;
                            while (true)
                            {
                              return localNode;
                              if (45 != k)
                                break label195;
                              l = this.mPage.getCharacter(this.mCursor);
                              if (65535 != l)
                                break;
                              i = 1;
                            }
                            if (62 != l)
                              break;
                            i = 1;
                          }
                          this.mPage.ungetCharacter(this.mCursor);
                          j = 2;
                        }
                        label195: localNode = parseString(paramInt, paramBoolean);
                      }
                      if (45 != k)
                        break;
                      j = 3;
                    }
                  while (65535 != k);
                  localNode = parseString(paramInt, paramBoolean);
                }
                if (45 != k)
                  break;
                j = 4;
              }
              j = 2;
            }
            if (62 != k)
              break;
            i = 1;
          }
        while ((Character.isWhitespace(k)) || ((!(STRICT_REMARKS)) && (((45 == k) || (33 == k)))));
        j = 2;
      }
      label302: localNode = makeRemark(paramInt, this.mCursor.getPosition());
    }
  }

  protected Node parseString(int paramInt, boolean paramBoolean)
    throws ParserException
  {
    int i = 0;
    int j = 0;
    while (true)
    {
      while (true)
      {
        label141: label155: label249: int l;
        while (true)
        {
          int k;
          label440: 
          do
            while (true)
            {
              while (true)
              {
                int i1;
                int i3;
                while (true)
                {
                  int i4;
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        int i5;
                        do
                        {
                          while (true)
                          {
                            while (true)
                            {
                              while (true)
                              {
                                while (true)
                                {
                                  int i7;
                                  while (true)
                                  {
                                    int i6;
                                    while (true)
                                    {
                                      while (true)
                                      {
                                        if (i != 0)
                                          break label554;
                                        k = this.mPage.getCharacter(this.mCursor);
                                        if (65535 != k)
                                          break;
                                        i = 1;
                                      }
                                      if (27 != k)
                                        break label155;
                                      i6 = this.mPage.getCharacter(this.mCursor);
                                      if (65535 != i6)
                                        break;
                                      i = 1;
                                    }
                                    if (36 != i6)
                                      break label141;
                                    i7 = this.mPage.getCharacter(this.mCursor);
                                    if (65535 != i7)
                                      break;
                                    i = 1;
                                  }
                                  if (66 != i7)
                                    break;
                                  scanJIS(this.mCursor);
                                }
                                this.mPage.ungetCharacter(this.mCursor);
                                this.mPage.ungetCharacter(this.mCursor);
                              }
                              this.mPage.ungetCharacter(this.mCursor);
                            }
                            if ((!(paramBoolean)) || (j != 0) || ((39 != k) && (34 != k)))
                              break;
                            j = k;
                          }
                          if ((!(paramBoolean)) || (j == 0) || (92 != k))
                            break label249;
                          i5 = this.mPage.getCharacter(this.mCursor);
                        }
                        while ((65535 == i5) || (92 == i5) || (i5 == j));
                        this.mPage.ungetCharacter(this.mCursor);
                      }
                      if ((!(paramBoolean)) || (k != j))
                        break;
                      j = 0;
                    }
                    if ((!(paramBoolean)) || (j != 0) || (k != 47))
                      break label440;
                    i1 = this.mPage.getCharacter(this.mCursor);
                    if (65535 != i1)
                      break;
                    i = 1;
                  }
                  if (47 != i1)
                    break;
                  do
                    do
                      i4 = this.mPage.getCharacter(this.mCursor);
                    while (65535 == i4);
                  while (10 != i4);
                }
                if (42 != i1)
                  break;
                do
                  do
                  {
                    int i2;
                    do
                      i2 = this.mPage.getCharacter(this.mCursor);
                    while ((65535 != i2) && (42 != i2));
                    i3 = this.mPage.getCharacter(this.mCursor);
                    if (i3 == 42)
                      this.mPage.ungetCharacter(this.mCursor);
                  }
                  while (65535 == i3);
                while (47 != i3);
              }
              this.mPage.ungetCharacter(this.mCursor);
            }
          while ((j != 0) || (60 != k));
          l = this.mPage.getCharacter(this.mCursor);
          if (65535 != l)
            break;
          i = 1;
        }
        if ((47 != l) && (!(Character.isLetter(l))) && (33 != l) && (37 != l) && (63 != l))
          break;
        i = 1;
        this.mPage.ungetCharacter(this.mCursor);
        this.mPage.ungetCharacter(this.mCursor);
      }
      this.mPage.ungetCharacter(this.mCursor);
    }
    label554: return makeString(paramInt, this.mCursor.getPosition());
  }

  protected Node parseTag(int paramInt)
    throws ParserException
  {
    int i = 0;
    Vector localVector = new Vector();
    int j = 0;
    int[] arrayOfInt = new int[8];
    arrayOfInt[0] = this.mCursor.getPosition();
    while (true)
    {
      while (true)
      {
        int k;
        do
          while (true)
          {
            while (true)
            {
              do
                while (true)
                {
                  while (true)
                  {
                    do
                      while (true)
                      {
                        while (true)
                        {
                          do
                            while (true)
                            {
                              while (true)
                              {
                                do
                                  while (true)
                                  {
                                    while (true)
                                    {
                                      while (true)
                                      {
                                        while (true)
                                        {
                                          do
                                            while (true)
                                            {
                                              while (true)
                                              {
                                                while (true)
                                                {
                                                  do
                                                    while (true)
                                                    {
                                                      if (i != 0)
                                                        break label669;
                                                      arrayOfInt[(j + 1)] = this.mCursor.getPosition();
                                                      k = this.mPage.getCharacter(this.mCursor);
                                                      switch (j)
                                                      {
                                                      default:
                                                        throw new IllegalStateException("how the fuck did we get in state " + j);
                                                      case 0:
                                                        if ((65535 != k) && (62 != k) && (60 != k))
                                                          break;
                                                        if (60 == k)
                                                        {
                                                          this.mPage.ungetCharacter(this.mCursor);
                                                          arrayOfInt[(j + 1)] = this.mCursor.getPosition();
                                                        }
                                                        whitespace(localVector, arrayOfInt);
                                                        i = 1;
                                                      case 1:
                                                      case 2:
                                                      case 3:
                                                      case 4:
                                                      case 5:
                                                      case 6:
                                                      }
                                                    }
                                                  while (Character.isWhitespace(k));
                                                  whitespace(localVector, arrayOfInt);
                                                  j = 1;
                                                }
                                                if ((65535 != k) && (62 != k) && (60 != k))
                                                  break;
                                                if (60 == k)
                                                {
                                                  this.mPage.ungetCharacter(this.mCursor);
                                                  arrayOfInt[(j + 1)] = this.mCursor.getPosition();
                                                }
                                                standalone(localVector, arrayOfInt);
                                                i = 1;
                                              }
                                              if (!(Character.isWhitespace(k)))
                                                break;
                                              arrayOfInt[6] = arrayOfInt[2];
                                              j = 6;
                                            }
                                          while (61 != k);
                                          j = 2;
                                        }
                                        if ((65535 != k) && (62 != k))
                                          break;
                                        empty(localVector, arrayOfInt);
                                        i = 1;
                                      }
                                      if (39 != k)
                                        break;
                                      j = 4;
                                      arrayOfInt[4] = arrayOfInt[3];
                                    }
                                    if (34 != k)
                                      break;
                                    j = 5;
                                    arrayOfInt[5] = arrayOfInt[3];
                                  }
                                while (Character.isWhitespace(k));
                                j = 3;
                              }
                              if ((65535 != k) && (62 != k))
                                break;
                              naked(localVector, arrayOfInt);
                              i = 1;
                            }
                          while (!(Character.isWhitespace(k)));
                          naked(localVector, arrayOfInt);
                          arrayOfInt[0] = arrayOfInt[4];
                          j = 0;
                        }
                        if (65535 != k)
                          break;
                        single_quote(localVector, arrayOfInt);
                        i = 1;
                      }
                    while (39 != k);
                    single_quote(localVector, arrayOfInt);
                    arrayOfInt[0] = (1 + arrayOfInt[5]);
                    j = 0;
                  }
                  if (65535 != k)
                    break;
                  double_quote(localVector, arrayOfInt);
                  i = 1;
                }
              while (34 != k);
              double_quote(localVector, arrayOfInt);
              arrayOfInt[0] = (1 + arrayOfInt[6]);
              j = 0;
            }
            if (65535 != k)
              break;
            standalone(localVector, arrayOfInt);
            arrayOfInt[0] = arrayOfInt[6];
            this.mPage.ungetCharacter(this.mCursor);
            j = 0;
          }
        while (Character.isWhitespace(k));
        if (61 != k)
          break;
        arrayOfInt[2] = arrayOfInt[6];
        arrayOfInt[3] = arrayOfInt[7];
        j = 2;
      }
      standalone(localVector, arrayOfInt);
      arrayOfInt[0] = arrayOfInt[6];
      this.mPage.ungetCharacter(this.mCursor);
      j = 0;
    }
    label669: return makeTag(paramInt, this.mCursor.getPosition(), localVector);
  }

  public void reset()
  {
    getPage().reset();
    setCursor(new Cursor(getPage(), 0));
  }

  protected void scanJIS(Cursor paramCursor)
    throws ParserException
  {
    int i = 0;
    int j = 0;
    while (true)
    {
      while (true)
      {
        int k;
        while (true)
        {
          while (true)
          {
            while (true)
            {
              do
              {
                while (true)
                {
                  if (i != 0)
                    return;
                  k = this.mPage.getCharacter(paramCursor);
                  if (65535 != k)
                    break;
                  i = 1;
                }
                switch (j)
                {
                default:
                  throw new IllegalStateException("state " + j);
                case 0:
                case 1:
                case 2:
                }
              }
              while (27 != k);
              j = 1;
            }
            if (40 != k)
              break;
            j = 2;
          }
          j = 0;
        }
        if (74 != k)
          break;
        i = 1;
      }
      j = 0;
    }
  }

  public void setCursor(Cursor paramCursor)
  {
    if (paramCursor == null)
      throw new IllegalArgumentException("cursor cannot be null");
    this.mCursor = paramCursor;
  }

  public void setNodeFactory(NodeFactory paramNodeFactory)
  {
    if (paramNodeFactory == null)
      throw new IllegalArgumentException("node factory cannot be null");
    this.mFactory = paramNodeFactory;
  }

  public void setPage(Page paramPage)
  {
    if (paramPage == null)
      throw new IllegalArgumentException("page cannot be null");
    this.mPage = paramPage;
  }

  public void setPosition(int paramInt)
  {
    getCursor().setPosition(paramInt);
  }
}